﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

using System.Diagnostics;
using System.Reflection;

namespace Smt.Asm.Api.Helper
{
    public class ParamHelper
    {

        public static T GetRequestEntity<T>()
        {
            var instream = System.Web.HttpContext.Current.Request.InputStream;

            var stream = StringHelper.GetHttpRequestParams(instream);

            var safeStr = StringHelper.GetSafeRequestParam(stream);
            StackTrace trace = new StackTrace();
            MethodBase methodName = trace.GetFrame(1).GetMethod();
            
            return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(safeStr);
        }

        /// <summary>
        /// 获取Requester接收参数
        /// </summary>
        /// <returns></returns>
        public static object GetRequestEntity(Stream instream)
        {
            var stream = StringHelper.GetHttpRequestParams(instream);
            var safeStr = StringHelper.GetSafeRequestParam(stream);

            return Newtonsoft.Json.JsonConvert.DeserializeObject<object>(safeStr);
        }



    }
}